import request from '@/utils/request'

export const departmentService = {
  // 获取部门列表
  getDepartments(params) {
    return request({
      url: '/departments',
      method: 'get',
      params
    })
  },
  
  // 获取部门详情
  getDepartmentDetail(id) {
    return request({
      url: `/departments/${id}`,
      method: 'get'
    })
  },
  
  // 创建部门
  createDepartment(data) {
    return request({
      url: '/departments',
      method: 'post',
      data
    })
  },
  
  // 更新部门
  updateDepartment(id, data) {
    return request({
      url: `/departments/${id}`,
      method: 'put',
      data
    })
  },
  
  // 删除部门
  deleteDepartment(id) {
    return request({
      url: `/departments/${id}`,
      method: 'delete'
    })
  },
  
  // 获取部门树
  getDepartmentTree() {
    return request({
      url: '/departments/tree',
      method: 'get'
    })
  }
}